#ifndef MAP_H_INCLUDED
#define MAP_H_INCLUDED

namespace Oribi
{
    #define N_TERRAIN_TYPES 2
    #define MAP_TILE_GRASS 0
    #define MAP_TILE_SAND  1

    struct MapTile
    {
        MapTile();

        int type;
        int height;

        static const int xSize = 32;
        static const int ySize = 16;
        static const int xSizeHalf = 16;
        static const int ySizeHalf = 8;
        static const int spriteHeight = 48;
    };

    #define DEFAULT_MAP_SIZE 256

    class Sprite;
    class GraphicContext;
    class Map
    {
    public:
        Map();
        Map(int s);
       ~Map();

        void initialise(int s = DEFAULT_MAP_SIZE);
        void render(GraphicContext& grc);

        int getTileHeight(int x, int y) const;

        bool initSprites(Resources&);
        void generateMap(int);
    private:
        void allocateTiles(int s = 0);

        Sprite *sprites;
        int size;
        MapTile *tiles;
    };
}

SDL_Point tilePosition(int x, int y, int height);
SDL_Point invTilePosition(int x, int y);

#endif // MAP_H_INCLUDED
